﻿//**********************************************************************************************//
//                                                                                              //
//Author:       Ja'Michael Garcia                                                               //
//Class Name:   AudioClip.cs                                                                    //
//Purpose:      Allows easier control of a sound effect                                         //
//Date :        December 2012                                                                   //
//                                                                                              //
//**********************************************************************************************//


using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;


namespace Indie_Game_Contest
{
    public class AudioClip : Microsoft.Xna.Framework.Game
    {
            private SoundEffectInstance audioController;
            private SoundEffect audio;
            private float fVolume;
            private float fPitch;
            private float fPan;
            private bool fLoop;

            public bool FLoop
            {
                get { return fLoop; }
                set { fLoop = value; }
            }

            public float FPitch
            {
                get { return fPitch; }
                set { fPitch = value; }
            }

            public float FPan
            {
                get { return fPan; }
                set { fPan = value; }
            }


            public float FVolume
            {
                get { return fVolume; }
                set { fVolume = value; }
            }

            public SoundEffectInstance AudioController
            {
                get { return audioController; }
                set { audioController = value; }
            }


            public SoundEffect Audio
            {
                get { return audio; }
                set { audio = value; }
            }

           public void LoadAudio( string szFileDirectory )
           {
               Audio = Content.Load<SoundEffect>(szFileDirectory);
           }

            public void SyncControllerToSound()
            {
                audioController = Audio.CreateInstance();
            }

            // Current not working
            public void LoadContent(float fVolume, float fPitch, float fPan, bool fLoop, string szFileDirectory)
            {
                FVolume = fVolume;
                FPitch = fPitch;
                FPan = fPan;
                FLoop = fLoop;

                LoadAudio(szFileDirectory);
                SyncControllerToSound();
            }
            
             // Working
            public void LoadContent(float fVolume, float fPitch, float fPan, bool fLoop, SoundEffect SFX)
            {
                FVolume = fVolume;
                FPitch = fPitch;
                FPan = fPan;
                FLoop = fLoop;
                Audio = SFX;
                //LoadAudio(szFileDirectory);
                SyncControllerToSound();
            }

         public SoundState currentState(  )
        {
            return audioController.State;
        }

    }
}
